home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Light ROM 1
/
LIGHT-ROM 1 (Amiga Library Services)(1994).iso
/
ffdisks
/
d938.lha
/
Angie
/
ImportedModules.lha
/
SPrintf.mod
< prev
Wrap
Text File
|
1993-09-07
|
6KB
|
165 lines
(* ------------------------------------------------------------------------
:Program. SPrintf.mod
:Contents. var args sprintf for Amiga-Oberon
:Author. Franz Schwarz
:Copyright. Public Domain
:Language. Oberon-2
:Translator. Amiga Oberon 3.00
:History. SPrintf.mod 1.0 (7.9.93) fSchwarz
:Address. Mühlenstraße 2, D-78591 Durchhausen, Germany / R.F.A.
:Address. uucp: Franz.Schwarz@mil.ka.sub.org; Fido: 2:241/7506.18
:Remark. As of Amiga Oberon Release 3.00: possible odd pointers to
:Remark. array of char/byte: _don't_ compile with OddChk. The
:Remark. compiler's options stack is broken as of Amiga-Oberon 3.00
--------------------------------------------------------------------------- *)
MODULE SPrintf;
IMPORT
e := Exec, y := SYSTEM;
TYPE
FakeBasePtr = UNTRACED POINTER TO FakeBase;
FakeBase = STRUCT
code1 : LONGINT;
jmp1 : e.PROC;
END;
CONST
fkBase = FakeBase (4E714EF9H, NIL);
(* nop *
* jmp 0x00000000 *)
VAR
FkBase : FakeBasePtr;
FkBaseS: FakeBase;
(****** SPrintf/SPrintf ****************************************************
*
* NAME
* SPrintf -- varargs sprintf output formatting using Exec.RawDoFmt
* SPrintF -- varargs sprintf output formatting without result code
* VSPrintf -- vector sprintf output formatting using Exec.RawDoFmt
* VSPrintF -- vector sprintf output formatting without result code
*
* SYNOPSIS
* SPrintf (buffer: ARRAY OF CHAR;
* format: ARRAY OF CHAR;
* args..: Exec.APTR ): LONGINT;
*
* SPrintF (buffer: ARRAY OF CHAR;
* format: ARRAY OF CHAR;
* args..: Exec.APTR );
*
* VSPrintf (buffer: ARRAY OF CHAR;
* format: ARRAY OF CHAR;
* args : Exec.APTR ): LONGINT;
*
* VSPrintF (buffer: ARRAY OF CHAR;
* format: ARRAY OF CHAR;
* args : Exec.APTR );
*
* FUNCTION
* These functions are full featured implementations of sprintf()/
* vsprintf(), supporting also the nifty varargs paramters provided
* by Amiga-Oberon for library calls. Due to the fact that these
* functions are implemented as library functions, you may pass NIL
* for the buffer ARRAY OF CHAR parameter which makes this function
* doing nothing but returning the length WITHOUT the trailing null
* byte of the generated output.
*
* INPUTS
* buffer - the buffer into which the output is written or NIL
* format - the format string with the formatting directives.
* For a detailed description of all possible directives
* have a look at Exec/RawDoFmt(). *ALL* directives
* except of %s/%b require a leading 'l' right before the
* type character, e.g. '%ld', '%08lx' or '%lc' instead of
* '%d', '%08x' or '%c'. This is true for Dos/Printf() and
* similar functions as well.
* args - the arguments to be included into the generated
* string according to the directives specified in the
* format string. Either as varargs for SPrintf()/SPrintF()
* or as a pointer to the arguemnts for VSPrintf()/
* VSPrintF()
*
* RESULT
* LONGINT - the length of the generated output WITHOUT the trailing
* null byte, which is actually written into the buffer
* as the last byte.
*
* SEE ALSO
* Exec/RawDoFmt(), Dos/Printf()
*
*****************************************************************************)
PROCEDURE SPrintf * {FkBase, 0} (buffer{11}: ARRAY OF CHAR;
format{8} : ARRAY OF CHAR;
args{9}.. : e.APTR ): LONGINT;
PROCEDURE SPrintF * {FkBase, 0} (buffer{11}: ARRAY OF CHAR;
format{8} : ARRAY OF CHAR;
args{9}.. : e.APTR );
PROCEDURE VSPrintf * {FkBase, 0} (buffer{11}: ARRAY OF CHAR;
format{8} : ARRAY OF CHAR;
args{9} : e.APTR ): LONGINT;
PROCEDURE VSPrintF * {FkBase, 0} (buffer{11}: ARRAY OF CHAR;
format{8} : ARRAY OF CHAR;
args{9} : e.APTR );
PROCEDURE SPrintFInternal();
(* $EntryExitCode- *)
BEGIN
y.INLINE (048E7U,00032U,04FEFU,0FFF8U,02F4BU,00004U,04297U,0264FU,
045FAU,0001AU,02C79U,00000U,00004U,04EAEU,0FDF6U,02017U,
04FEFU,00008U,04CDFU,04C00U,05380U,04E75U,02F0CU,05293U,
04AABU,00004U,0670AU,0286BU,00004U,01880U,052ABU,00004U,
0285FU,04E75U );
(*
* 00.00000000 48e7 0032 MOVEM.L A2-A3/A6,-(A7)
* 00.00000004 4fef fff8 LEA.L fff8(A7),A7
* 00.00000008 2f4b 0004 MOVE.L A3,0004(A7)
* 00.0000000c 4297 CLR.L (A7)
* 00.0000000e 264f MOVEA.L A7,A3
* 00.00000010 45fa 001a LEA.L 002c(pc),A2
* 00.00000014 2c79 0000 0004 MOVEA.L 00000004,A6
* 00.0000001a 4eae fdf6 JSR fdf6(A6)
* 00.0000001e 2017 MOVE.L (A7),D0
* 00.00000020 4fef 0008 LEA.L 0008(A7),A7
* 00.00000024 4cdf 4c00 MOVEM.L (A7)+,A2-A3/A6
* 00.00000028 5380 SUBQ.L #1,D0
* 00.0000002a 4e75 RTS
* 00.0000002c 2f0c MOVE.L A4,-(A7)
* 00.0000002e 5293 ADDQ.L #1,(A3)
* 00.00000030 4aab 0004 TST.L 0004(A3)
* 00.00000034 670a BEQ.B 00000040
* 00.00000036 286b 0004 MOVEA.L 0004(A3),A4
* 00.0000003a 1880 MOVE.B D0,(A4)
* 00.0000003c 52ab 0004 ADDQ.L #1,0004(A3)
* 00.00000040 285f MOVEA.L (A7)+,A4
* 00.00000042 4e75 RTS
*)
END SPrintFInternal;
BEGIN
FkBaseS := fkBase;
FkBase := y.ADR (FkBaseS);
FkBase.jmp1 := SPrintFInternal;
IF e.exec.libNode.version >= 37 THEN e.CacheClearU(); END;
CLOSE
(* nop *)
END SPrintf.